import { Constants } from "./etc/Constants";
import { LogicDriver } from "./etc/LogicDriver";
import { updateTween } from "./etc/Tween";
import { BoutModuleS, BoutModuleC } from "./modules/BoutModule";
import { GuiModuleS, GuiModuleC } from "./modules/GuiModule";
import { ItemModuleS, ItemModuleC, ItemModuleData } from "./modules/ItemModule";
import { PlayerModuleS, PlayerModuleC, PlayerModuleData } from "./modules/PlayerModule";
import { SoundModuleC, SoundModuleS } from "./modules/SoundModule";
import { MotionModuleC, MotionModuleS } from "./motion/MotionModule";


@Component
export default class GameLauncher extends mw.Script {
    
    protected onStart() {
        this.registerModules()
        DataStorage.setTemporaryStorage(SystemUtil.isPIE);
        setInterval(LogicDriver.update, Constants.LogicFrameInterval * 960);
        this.useUpdate = true;
    }

    protected onUpdate(dt: number): void {
        updateTween();
    }

    private registerModules() {
        ModuleService.registerModule(ItemModuleS, ItemModuleC, ItemModuleData)
        ModuleService.registerModule(PlayerModuleS, PlayerModuleC, PlayerModuleData)
        ModuleService.registerModule(BoutModuleS, BoutModuleC, null)
        ModuleService.registerModule(GuiModuleS, GuiModuleC, null)
        ModuleService.registerModule(MotionModuleS, MotionModuleC, null)
        ModuleService.registerModule(SoundModuleS, SoundModuleC, null)
    }
}